﻿//-----------------------------------------------------------------------
// <copyright>
// This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
// </copyright>
//----------------------------------------------------------------------- 
using System;
using System.IO;
using System.Text;
using Fulcrum.ControlGenerator;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Fulcrum.UnitTests.ControlGenerator
{
    class ControlGeneratorXmlConfigurationTestDouble : ControlGeneratorXmlConfiguration
    {
        int controlCount = 0;

        public ControlGeneratorXmlConfigurationTestDouble(string fileName) :
            base(fileName)
        {
            // nothing
        }

        protected override IControlConfiguration CreateControlConfiguration(System.Xml.XmlReader xmlReader)
        {
            Assert.AreEqual("Control", xmlReader.Name);

            var controlConfig = MockConfigurationHelp.CreateControlConfig(String.Format("ControlName{0}", controlCount++));

            xmlReader.Read();

            return controlConfig;
        }

        protected override Stream GetXmlStream(string file)
        {
            this.FileName = file;

            byte[] byteArray = Encoding.ASCII.GetBytes(ConfigurationXml); 
            var stream = new MemoryStream(byteArray);

            return stream;
        }

        public static string ConfigurationXml
        {
            get;
            set;
        }

        public string FileName
        {
            get;
            private set;
        }

        
    }
}
